/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "ConnectionManager.h"
#include "SystemUtil.h"
#include "ServiceManager.h"
#include "ServerSocket.h"
#include "Logger.h"
#include "PQException.h"
#include "PlayerSessionManager.h"

namespace PQServiceLogin
{
	/*Implement connection thread.
	*/
	class ConnectionThread :
		public PQCore::Thread
	{
	public:
		ConnectionThread();

		void run();//run this thread

	protected:
		PlayerSessionManager* _sessionManager;

	protected://state related
		bool _isActive;
	};

	ConnectionThread::ConnectionThread() : _isActive(true),_sessionManager(0)
	{
		//create player session manager.
		_sessionManager=new PlayerSessionManager();
		_sessionManager->init();
	}

	void ConnectionThread::run()
	{
		while(_isActive){
			threadSleep(100);
			_sessionManager->update();
		}
	}

	ConnectionManager::ConnectionManager(void)
	{
	}

	ConnectionManager::~ConnectionManager(void)
	{
	}

	void ConnectionManager::init()
	{
		//create connection thread
		_thread=new ConnectionThread();
		
	}

	void ConnectionManager::start()
	{
		_thread->start();
	}


}
